package cn.swust.designpatternlearningplatform.dao.sql;

import cn.swust.designpatternlearningplatform.domain.bo.TestPaperDataBo;
import cn.swust.designpatternlearningplatform.domain.entity.DailyExercise;
import cn.swust.designpatternlearningplatform.domain.entity.PaperResult;
import org.apache.ibatis.jdbc.SQL;

import java.time.LocalDateTime;

public class StudentTestDaoSql {


    public String insertScore(String paperNumber, String studentNumber, Integer sum){
        return new SQL(){
            {
                INSERT_INTO("student_test_paper_score");
                VALUES("paper_number","#{paperNumber}");
                VALUES("student_number","#{studentNumber}");
                VALUES("score","#{sum}");
            }
        }.toString();
    }
    /**
     * @param dailyExercise:
     * @return String
     * @author wang
     * description 将试卷的做题信息一起放进日常训练中
     * date 2023/5/14 13:34
     */
    public String insertDailyExercise(DailyExercise dailyExercise){
        LocalDateTime problemTime = dailyExercise.getProblemTime();
        String studentNumber = dailyExercise.getStudentNumber();
        Integer topicId = dailyExercise.getTopicId();
        String ownAnswer = dailyExercise.getOwnAnswer();
        Integer isRight = dailyExercise.getIsRight();

        return new SQL(){
            {

                INSERT_INTO("daily_exercise");
                VALUES("student_number","#{studentNumber}");
                VALUES("topic_id","#{topicId}");
                VALUES("own_answer","#{ownAnswer}");
                VALUES("is_right","#{isRight}");
                VALUES("problem_time","#{problemTime}");
            }
        }.toString();
    }
    /**
     * @param testPaperDataBo:
      * @return String
     * @author wang
     * description 获取试卷列表
     * date 2023/5/14 16:24
     */
    public String getTestList(TestPaperDataBo testPaperDataBo){
        String teacherNumber = testPaperDataBo.getTeacherNumber();
        String semester = testPaperDataBo.getSemester();
        String classNumber = testPaperDataBo.getClassNumber();
        return new SQL(){
            {
                SELECT("*");
                FROM("test_paper");
                WHERE("teacher_number=#{teacherNumber}","semester=#{semester}","class_number=#{classNumber}");
            }
        }.toString();
    }

}
